package leetcode.code209;

public class Solution extends Solution209 {

	@Override
	public int minSubArrayLen(int target, int[] nums) {
		int l = 0;
		int r = 0;
		int sum = 0;
		int result = Integer.MAX_VALUE;
		while (r < nums.length) {
			sum += nums[r];
			while (sum >= target) {
				result = Math.min(r - l + 1, result);
				sum -= nums[l];
				l++;
			}
			r++;
		}
		return result == Integer.MAX_VALUE ? 0 : result;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
	}

}
